import 'package:flutter/cupertino.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:my_meeting/theme.dart';

import 'generated/l10n.dart';
import 'global.dart';
import 'routes/router.dart';

export 'package:get/get.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Get.updateLocale(const Locale('en'));
  // Get.updateLocale(const Locale('zh'));

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Get.focusScope?.unfocus();
      },
      child: ScreenUtilInit(
        designSize: const Size(375, 812),
        minTextAdapt: true,
        splitScreenMode: true,
        builder: (_, __) => GetMaterialApp(
          title: 'MyMeetting',
          debugShowCheckedModeBanner: false,
          defaultTransition: Transition.cupertino,
          theme: AppTheme().defaultTheme,
          getPages: AppRoutes.routes,
          initialRoute: AppRoutes.splash,
          navigatorKey: navigatorKey,
          builder: FToastBuilder(),
          initialBinding: GlobalBinding(),
          localizationsDelegates: const [
            S.delegate,
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          locale: Get.locale ?? Get.deviceLocale ?? const Locale('en', 'En'),
          supportedLocales: S.delegate.supportedLocales,
        ),
      ),
    );
  }
}
